package com.dj.common.web.rest;

import org.springframework.data.domain.Page;

public class PaginationInfo {

	/**
	 * 偏移量，相当于是起始记录
	 */
	private final int offset;

	/**
	 * 一个页面的记录数量，
	 */
	private final int pageSize;

	/**
	 * The max number of records available. 
	 */
	private final long totalCount;
	

	private final long totalPage;
	
	private final long currentPage;

	private final int rows;
	private final int total;
	

	public PaginationInfo() {
		this(0, 0);
	}

	public PaginationInfo(int offset, int countInPage) {
		super();
		this.offset = offset;
		this.pageSize = countInPage;
		this.totalCount = -1L;
		this.totalPage = -1L;
		this.currentPage = -1L;
		this.rows = 100;
		this.total = 100;
	}

	public PaginationInfo(int offset, int countInPage, long totalCount) {
		super();
		this.offset = offset;
		this.pageSize = countInPage;
		this.totalCount = totalCount;
		this.totalPage = -1L;
		this.currentPage = -1L;
		this.rows = 100;
		this.total = 100;
	}

	public PaginationInfo(Page<?> page) {
		super();
		this.offset = page.getNumber() * page.getSize();
		this.pageSize = page.getNumberOfElements();
		this.totalCount = page.getTotalElements();
		this.totalPage = page.getTotalPages();
		this.currentPage = page.getNumber();
		this.rows = 100;
		this.total = 100;
	}

	public int getOffset() {
		return offset;
	}

	public int getCountInPage() {
		return pageSize;
	}

	public long getTotalCount() {
		return totalCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public long getTotalPage() {
		return totalPage;
	}

	public long getCurrentPage() {
		return currentPage;
	}

	public int getRows() {
		return rows;
	}

	public int getTotal() {
		return total;
	}


}
